/**
 * 跳转软件详情页
 * @param {软件详情} id
 */
export const gotoDetail = (item, router, axios) => {
  if(!item.thirdPartyUrl){
    const { href } = router.resolve({
      name: "detail",
      params: {
        id: item.id,
      },
    });
    window.open(href, "_blank");
  }else{
    window.axios.get('/api/download/common/visitPage/'+window.btoa(item.thirdPartyUrl)+'.html')
    window.open(item.thirdPartyUrl, "_blank");
  }
};
/**
 * 跳转软件列表页
 * @param {软件详情} id
 */
export const gotoRouter = (path, router ,params, routerName ,isBlank=true) => {
  console.log(path);
  let obj = routerName?{
      name: routerName,
      params: params||{}
  }:{
      path: path,
      params: params||{}
  }
  const { href } = router.resolve(obj);
  window.open(href, isBlank?"_blank":'_self');
};

/**
 * 跳转软件列表页 游戏列表
 * @param {软件详情} id
 */
export const gotoList = (param, router,isBlank=true) => {
  if(param.substring(0,3) == "389"){
    if(param.substring(4,7) == "410"){
      const { href } = router.resolve({
        name: "game-web-list",
        params: {
          param: param,
        },
      });
      window.open(href, isBlank?"_blank":'_self');
    }else{
      const { href } = router.resolve({
        name: "game-alone-ist",
        params: {
          param: param,
        },
      });
      window.open(href, isBlank?"_blank":'_self');
    }
  }else if(param.substring(0,3) == "384"){
    const { href } = router.resolve({
      name: "game-mobile-index",
      params: {
        param: param,
      },
    });  
    window.open(href, isBlank?"_blank":'_self');

  }else{
    const { href } = router.resolve({
      name: "page",
      params: {
        param: param,
      },
    });
    window.open(href, isBlank?"_blank":'_self');
  }
};
